package com.zc.trendsDispatch.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.zc.component.gateway.annotation.Subscribe;
import com.zc.core.message.property.ReportPropertyMessage;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zc.trendsDispatch.domain.ChargeStationStrategy;
import com.zc.trendsDispatch.service.IChargeStationStrategyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import reactor.core.publisher.Mono;

/**
 * 场站调度策略Controller
 *
 * @author glb
 * @date 2024-02-03
 */
@RestController
@RequestMapping("/trendsDispatch/strategy")
public class ChargeStationStrategyController extends BaseController
{
    @Autowired
    private IChargeStationStrategyService chargeStationStrategyService;

    /**
     * 查询场站调度策略列表
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:strategy:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChargeStationStrategy chargeStationStrategy)
    {
        startPage();
        List<ChargeStationStrategy> list = chargeStationStrategyService.selectChargeStationStrategyList(chargeStationStrategy);
        return getDataTable(list);
    }

    /**
     * 导出场站调度策略列表
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:strategy:export')")
    @Log(title = "场站调度策略", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChargeStationStrategy chargeStationStrategy)
    {
        List<ChargeStationStrategy> list = chargeStationStrategyService.selectChargeStationStrategyList(chargeStationStrategy);
        ExcelUtil<ChargeStationStrategy> util = new ExcelUtil<>(ChargeStationStrategy.class);
        util.exportExcel(response, list, "场站调度策略数据");
    }

    /**
     * 获取场站调度策略详细信息
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:strategy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(chargeStationStrategyService.selectChargeStationStrategyById(id));
    }

    /**
     * 新增场站调度策略
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:strategy:add')")
    @Log(title = "场站调度策略", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargeStationStrategy chargeStationStrategy)
    {
        return toAjax(chargeStationStrategyService.insertChargeStationStrategy(chargeStationStrategy));
    }

    /**
     * 修改场站调度策略
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:strategy:edit')")
    @Log(title = "场站调度策略", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargeStationStrategy chargeStationStrategy)
    {
        return toAjax(chargeStationStrategyService.updateChargeStationStrategy(chargeStationStrategy));
    }

    /**
     * 删除场站调度策略
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:strategy:remove')")
    @Log(title = "场站调度策略", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(chargeStationStrategyService.deleteChargeStationStrategyByIds(ids));
    }

    /**
     * 获取场站调度策略详负载电表
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:strategy:getLoad')")
    @GetMapping(value = "/getLoad")
    public AjaxResult getLoad(ChargeStationStrategy chargeStationStrategy )
    {
        return AjaxResult.success(chargeStationStrategyService.getLoad(chargeStationStrategy));
    }






}
